var app = getApp();
Page({
  data: {
  },

  onLoad: function() {
    var store_id = wx.getStorageSync("store_id");
    var account_id = wx.getStorageSync("account_id");
    console.log(store_id)
    if(!store_id || !account_id){
      app.showToast("请登录小程序")
      wx.navigateBack();
    }else{
      this.setData({
        store_id:wx.getStorageSync("store_id"),
        account_id:wx.getStorageSync("account_id")
      })
      this.getProfitSituationJB();
    }
  },

  getProfitSituationJB:function(){
    var t = this;
    app.visit("account/getProfitSituationJB", {
      store_id:t.data.store_id,
      account_id:t.data.account_id,
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          info:c.data.info,
          total_price:c.data.zong_price,
          total_num:c.data.zong_num,
          xswxzf_price:c.data.xs.wxzf_price,
          xswxzf_num:c.data.xs.wxzf_num,
          xsfpzf_price:c.data.xs.fpzf_price,
          xsfpzf_num:c.data.xs.fpzf_num,
          xxwxzf_price:c.data.sm.wxzf_price,
          xxwxzf_num:c.data.sm.wxzf_num,
          xxbtzf_price:c.data.sm.btzf_price,
          xxbtzf_num:c.data.sm.btzf_num,
          xxhbzf_price:c.data.sm.yezf_price,
          xxhbzf_num:c.data.sm.yezf_num,
          xsyezf_price:c.data.xs.yezf_price,
          xsyezf_num:c.data.xs.yezf_num,
          xshbzf_price:c.data.xs.hbzf_price,
          xshbzf_num:c.data.xs.hbzf_num,
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  setXZ:function(e){
    var jbyg_name = e.detail.value;
    console.log(jbyg_name)
    this.setData({
      jbyg_name:jbyg_name
    })
  },

  tijiao:function(){
    var t = this;
    var store_id = wx.getStorageSync("store_id");
    var account_id = wx.getStorageSync("account_id");
    if(!store_id || !account_id){
      app.showToast("请登录小程序")
      wx.navigateBack();
    }else{
      wx.showModal({
        title: '提示',
        content: '确认交接班吗',
        success: function (res) {
          if (res.confirm) {
            app.visit("account/setStoreChangeShifts", {
              store_id:store_id,
              account_id:account_id,
              total_price:t.data.total_price,
              total_num:t.data.total_num,
              xswxzf_price:t.data.xswxzf_price,
              xswxzf_num:t.data.xswxzf_num,
              xsfpzf_price:t.data.xsfpzf_price,
              xsfpzf_num:t.data.xsfpzf_num,
              xshbzf_price:t.data.xshbzf_price,
              xshbzf_num:t.data.xshbzf_num,
              xxwxzf_price:t.data.xxwxzf_price,
              xxwxzf_num:t.data.xxwxzf_num,
              xxbtzf_price:t.data.xxbtzf_price,
              xxbtzf_num:t.data.xxbtzf_num,
              xxyezf_price:t.data.xxhbzf_price,
              xxyezf_num:t.data.xxhbzf_num,
              jbyg_name:t.data.jbyg_name,
            }, "", function(c) {
              console.log(c)
              if(0 == c.code){
                wx.showToast({
                  title: c.msg,
                  icon: 'none',
                  duration: 3000,
                  success:function () {
                    wx.setStorageSync("store_id","");
                    wx.setStorageSync("account_id","");
                    wx.navigateTo({
                      url: 'index'
                    });
                  }
                })
              }else{
                app.showToast(c.msg)
              }
            })
          } else {//这里是点击了取消以后
            console.log('用户点击取消')
          }
        }
      })
    }
  }

})